fix: clean up downloaded helper scripts after install#46
Merged
Conversation
The installer left two helper scripts on disk after a successful run: the downloaded `ee` script (from `wget -qO ee https://rt.cx/ee4 && bash ee`) and `docker-setup.sh` fetched during Docker installation. setup.sh now removes itself on success. It self-deletes only when executed directly (BASH_SOURCE[0] == $0), so a sourced run (e.g. remote-migrate) or a piped `curl ... | bash` removes nothing; the path is resolved to an absolute form so a later chdir can't strand it, and EE_KEEP_INSTALLER=1 opts out. setup_docker downloads the Docker helper into TMP_WORK_DIR so the existing EXIT trap removes it on every exit path, including failures. Closes #15
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #15 by ensuring the installer no longer leaves behind downloaded helper scripts after installation completes successfully.
Changes:
- Add “self-delete on success” behavior to
setup.shwhen executed directly (with opt-out viaEE_KEEP_INSTALLER=1and safeguards for sourced/piped execution). - Download the Docker install helper into
TMP_WORK_DIRso it is cleaned up automatically by the existingEXITtrap.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| setup.sh | Captures the installer’s absolute path (when executed directly) and removes it after a successful install. |
| functions | Downloads the Docker installer script into TMP_WORK_DIR instead of the current working directory to ensure cleanup via the existing trap. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| sh docker-setup.sh | ||
| # Download into TMP_WORK_DIR so setup.sh's EXIT trap cleans it up on any | ||
| # exit path, instead of leaving docker-setup.sh behind in the CWD. | ||
| wget --quiet get.docker.com -O "$TMP_WORK_DIR/docker-setup" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #15.
After a successful install the installer left two downloaded helper scripts on disk. This cleans both up.
eeinstaller scriptThe canonical install (
wget -qO ee https://rt.cx/ee4 && sudo bash ee) leaves theeefile in the user's working directory.setup.shnow removes itself once the install succeeds.Guards:
BASH_SOURCE[0]equals$0when the script is run withbash ee, differs when it is sourced (e.g.remote-migratesources the installer over SSH), and is empty when piped (curl ... | bash). So sourced and piped runs delete nothing. UsingBASH_SOURCE[0]instead of$0also avoids the pipe case wrongly matching a file literally namedbashin the current directory.cdcan't leave it behind.EE_KEEP_INSTALLER=1(useful when running a checkout in place).set -eexits earlier and the file is left for a retry.docker-setup.shsetup_docker()downloadedget.docker.comtodocker-setup.shin the current directory and never removed it. It now downloads intoTMP_WORK_DIR, so the existingEXITtrap insetup.shcleans it up on every exit path — including download/install failures.Testing
Verified in an
ubuntu:24.04container (bash 5.2.21):bash ee→ removes itself;curl | bash→ removes nothing (even with abashfile in CWD); sourced run → file kept;EE_KEEP_INSTALLER=1→ kept;cdbefore delete → still removes the right file.docker-setup.shleft in CWD.